import paste.deploy
from pylons.database import create_engine
import meilanblog.models as model

def setup_config(command, filename, section, vars):
    """
    Place any commands to setup meilanblog here.
    """
    conf = paste.deploy.appconfig('config:' + filename)
    conf.update(dict(app_conf=conf.local_conf, global_conf=conf.global_conf))
    paste.deploy.CONFIG.push_process_config(conf)

    uri = conf['sqlalchemy.dburi']
    engine = create_engine(uri)
    print "Connecting to database", uri
    model.meta.connect(engine)
    print "Creating tables"
    model.meta.drop_all()
    model.meta.create_all()

    print "Adding default data"
    model.add_option('blogname', "DemoBlog")
    model.add_option('version', '0.1')
    print "Successfully setup."
